import requests
import execjs
import re
import json

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36',
    'Referer': 'https://passport.kongzhong.com/'
}
url = 'https://sso.kongzhong.com/ajaxLogin?j=j&jsonp=j&service=https://passport.kongzhong.com/&_=1652688351025'

data = requests.get(url, headers=headers).text
ex = 'KZLoginHandler.jsonpCallbackKongZ\((.*)\)'
dc = json.loads(re.findall(ex, data)[0])['dc']

node = execjs.get()
ctx = node.compile(open('/Users/lidong/Desktop/zhouyu/BILIBILI/笔记/爬虫/kongzhongwang.js', encoding='utf-8').read())
funcName = "getpwd('{0}','{1}')".format("123", dc)
password = ctx.eval(funcName)
print(password)